﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using KEW.InterFace;

namespace AutoGam
{
    public partial class SalesForm : Form
    {
        private const int QtyLength = 3;
        private const int NumberLen = 8;
        private const int CarLength = 7;
        private Boolean isAutoMax = false;
        String OrgName = "";

        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ExStyle |= 0x02000000;
                return cp;
            }
        }

        public SalesForm()
        {
            InitializeComponent();
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
            SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲

            if (!Program.IsDebug)
            {
                this.TopMost = true;
                this.WindowState = FormWindowState.Maximized;
            }
        }



        private void PageSales_NumClear_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            PageSales_NumText.Text = String.Empty;
        }

        private void PageSales_NumDelete_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            if (PageSales_NumText.Text.Length > 0)
            {
                PageSales_NumText.Text = PageSales_NumText.Text.Substring(0, PageSales_NumText.Text.Length - 1);
            }
        }

        private void PageSales_Num_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            if (PageSales_NumText.Text.Length < NumberLen)
            {
                PageSales_NumText.Text += ((Button)sender).Text;
            }
        }

        private void PageSales_NumNext_Click(object sender, EventArgs e)
        {
            ButtonStart();
            if (PageSales_NumText.Text.Length == NumberLen)
            {
                Boolean isPass = false;
                
                String baseKey = PageSales_NumText.Text.Substring(0, 1);
                if (Program.DataConnString.ContainsKey(baseKey))
                {
                    DataSet data = new DataSet();
                    OleDbConnection conn = new OleDbConnection();
                    conn.ConnectionString = Program.DataConnString[baseKey];

                    String sql = String.Format("SELECT A.FName,A.FID,Isnull(B.FDecimal2,0) BagQty FROM KEW_ProductsEntry A LEFT JOIN KEW_ProductsBagRuleEntry B ON A.FBase1=B.FID\r\n");
                    sql += String.Format("SELECT A.FID,A.FText CarNo,A.FDecimal4 PreQty,Isnull(B.FID,0) ItemID,A.FNOTE,Isnull(B.FName,'') ItemName,C.FName OrgName FROM KEW_SalesInfo A LEFT JOIN KEW_ProductsEntry B ON A.FBase=B.FID LEFT JOIN t_Organization C ON A.FBase1=C.FItemID  WHERE A.FCheckBox4=0 AND A.FComboBox='-1' AND A.FText14='{0}'", PageSales_NumText.Text);
                    OleDbDataAdapter adapter = new OleDbDataAdapter(sql, conn);
                    try
                    {
                        PageSales_NumMessage.Text = "正在查询，请稍候...";
                        Device.Voice("voice1.wav");
                        Application.DoEvents();
                        DateTime now = DateTime.Now;
                        adapter.Fill(data);
                        //while ((DateTime.Now - now).TotalSeconds < 5)
                        //{
                        //    Application.DoEvents();
                        //    System.Threading.Thread.Sleep(10);
                        //}
                        if (data.Tables[0].Rows.Count > 0 && data.Tables[1].Rows.Count == 1)
                        {
                            isPass = true;
                            DataRow row = data.Tables[1].Rows[0];
                            BillID = row["FID"].ToString();
                            Note = row["FNote"].ToString();
                            OrgName = row["OrgName"].ToString();
                            PageCar_Text.Text = row["CarNo"].ToString().Trim();
                            PageSales_PreQty.Text = Convert.ToDecimal(row["PreQty"].ToString()).ToString("0.00");
                            PageSales_ItemList.DisplayMember = "Name";
                            PageSales_ItemList.ValueMember = "ID";
                            PageSales_ItemList.Items.Clear();

                            foreach (DataRow list in data.Tables[0].Rows)
                            {
                                ListTemp temp = new ListTemp();
                                temp.ID = list["FID"].ToString();
                                temp.Name = list["FName"].ToString();
                                PageSales_ItemList.Items.Add(temp);

                                if (row["ItemID"].ToString() == temp.ID)
                                {
                                    PageSales_ItemList.SelectedItem = temp;
                                }
                            }

                            PageCar_Panel.Enabled = (PageCar_Text.Text == "");
                            PageSales_ItemList.Enabled = (PageSales_ItemList.SelectedItem == null);
                            PageSales_QtyPanel.Enabled = (Common.CDec(PageSales_PreQty.Text) == 0);
                            SalesTab.SelectedTab = TabPageInuputCarNo;

                            //if (PageCar_Text.Text == "")
                            //{
                            //    SalesTab.SelectedTab = TabPageInuputCarNo;
                            //}
                            //else if (Common.CDec(PageSales_PreQty.Text) == 0 || PageSales_ItemList.SelectedItem == null)
                            //{
                            //    SalesTab.SelectedTab = TabPageSalesInuputPreQty;
                            //}
                            //else
                            //{
                            //    SalesTab.SelectedTab = TabPageSalesConfirm;
                            //}
                        }
                        else
                        {
                            PageSales_NumMessage.Text = "错误的编号。";
                            Device.Voice("编号不正确.wav");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                    conn.Dispose();
                }
                else
                {
                    PageSales_NumMessage.Text = "错误的编号。";
                    Device.Voice("编号不正确.wav");
                }
            }
            else
            {
                PageSales_NumMessage.Text = String.Format("您输入的编号长度不是{0}位。", NumberLen);
                Device.Voice("编号不正确.wav");
            }
            ButtonEnd();
        }

        private void PageCar_Next_Click(object sender, EventArgs e)
        {
            ButtonStart();
            if (PageCar_Text.Text != String.Empty)
            {
                SalesTab.SelectedTab = TabPageSalesInuputPreQty;
            }
            //if (PageSales_PreQty.Text == "" || PageSales_ItemList.SelectedItem == null)
            //{
            //    SalesTab.SelectedTab = TabPageSalesInuputPreQty;
            //    PageSales_ItemList.Enabled = (PageSales_ItemList.SelectedItem == null);
            //    PageSales_QtyPanel.Enabled = (PageSales_PreQty.Text == "");
            //}
            //else
            //{
            //    SalesTab.SelectedTab = TabPageSalesConfirm;
            //}
            ButtonEnd();
        }

        private void PageSales_QtyNext_Click(object sender, EventArgs e)
        {
            ButtonStart();
            if (PageSales_ItemList.SelectedItem == null)
            {
                PageSales_PreMessage.Text = "请选择一个产品！";
            }
            else if (Common.CDec(PageSales_PreQty.Text) == 0)
            {
                PageSales_PreMessage.Text = "请输入预装量！";
            }
            else
            {
                SalesTab.SelectedTab = TabPageSalesConfirm;
            }
            ButtonEnd();
        }

        DateTime ButtonOverTime = DateTime.Now;
        Boolean IsButtonEnable = true;

        private void ButtonStart()
        {
            Device.ButtonVoice();
            
            PageSales_NumNext.Enabled = false;
            PageSales_NumCancel.Enabled = false;
            PageCar_Next.Enabled = false;
            PageCar_Cancel.Enabled = false;
            PageSales_QtyNext.Enabled = false;
            PageSales_QtyCancel.Enabled = false;
            PageConfirm_Next.Enabled = false;
        }

        private void ButtonEnd()
        {
            ButtonOverTime = DateTime.Now;
            IsButtonEnable = false;
        }

        private void PageConfirm_Next_Click(object sender, EventArgs e)
        {
            ButtonStart();
            PageSales_NumNext.Enabled = false;
            PageConfirm_Message.Text = "请稍候，正在为您办理！";
            PageConfirm_Next.Text = "请 稍 候";
            Device.Voice("voice1.wav");
            PageConfirm_Next.Enabled = false;
            String itemID = ((ListTemp)PageSales_ItemList.SelectedItem).ID;


            Application.DoEvents();

            DataSet data = new DataSet();
            OleDbConnection conn = new OleDbConnection();
            conn.ConnectionString = Program.DataConnString[PageSales_NumText.Text.Substring(0, 1)];
            Decimal Qty = Common.Qty(PageSales_PreQty.Text);
            Decimal SumQty=0;
            Decimal SumBalQty = 0;
            Boolean IsInBag;

            StringBuilder sql = new StringBuilder();
            sql.AppendFormat("EXEC KEW_SALES_CHECKREADJUST\r\n");
            sql.AppendFormat("EXEC KEW_SALES_SETNEWPRICE '{0}','{1}'\r\n", BillID, itemID);
            sql.Append("SELECT A.FEntryID EntryID,E.FDecimal5 AmountBal,IsNull(D.FDecimal3,P.FDecimal2) FItemPrice,IsNull(D.FDecimal3,P.FDecimal2)+IsNull(A.FDecimal13,0)+IsNull(A.FDecimal14,0) FPrice,IsNull(D.FText,'挂牌价') FSource,P.FCheckBox IsInBag,G.FName GName \r\n");
            sql.Append("FROM KEW_SalesInfoEntry A LEFT JOIN KEW_SalesInfo B ON A.FID=B.FID \r\n");
            sql.AppendFormat("LEFT JOIN KEW_SalesAccount E ON E.FID=A.FID_SRC\r\n");
            sql.AppendFormat("LEFT JOIN KEW_SalesAccountEntry D ON E.FID=D.FID AND D.FBase2='{0}'\r\n", itemID);
            sql.AppendFormat("LEFT JOIN KEW_ProductsEntry P ON P.FID='{0}'\r\n", itemID);
            sql.AppendFormat("LEFT JOIN t_Organization G ON G.FItemID=B.FBase1\r\n");
            sql.AppendFormat("WHERE A.FID='{0}' AND A.FID_SRC>0 ORDER BY A.FIndex\r\n", BillID);
            sql.AppendFormat("SELECT 1 FROM KEW_SalesInfo WHERE FText='{0}' AND FComboBox IN ('0','1','2') AND FCheckBox4=0 AND FID!={1}", PageConfirmCar.Text, BillID);

            OleDbDataAdapter adapter = new OleDbDataAdapter(sql.ToString(), conn);
            
            AccountList.Clear();
            String[] GustName;
            try
            {
                adapter.Fill(data);
                IsInBag = Common.CBool(data.Tables[0].Rows[0]["IsInBag"].ToString());
                GustName = Com.Split(data.Tables[0].Rows[0]["GName"].ToString());
                

                foreach (DataRow row in data.Tables[0].Rows)
                {
                    AccountTemp temp = new AccountTemp();
                    temp.ID = row["EntryID"].ToString();
                    temp.AmountBal = Common.Amount(row["AmountBal"].ToString());
                    temp.ItemPrice = Common.Price(row["FItemPrice"].ToString());
                    temp.SumPrice = Common.Price(row["FPrice"].ToString());
                    if (temp.SumPrice <= 0)
                    {
                        PageConfirm_Message.Text = "产品单价出现错误，请联系管理员维护！";
                        PageConfirm_Next.Enabled = true;
                        PageConfirm_Next.Text = "确    定";
                        return;
                    }
                    temp.QtyBal = Common.CutDecimal(temp.AmountBal/temp.SumPrice, 2);
                    temp.Source = row["FSource"].ToString();

                    SumBalQty += temp.QtyBal;
                    if (Qty > temp.QtyBal)
                    {
                        temp.Qty = temp.QtyBal;
                        Qty = Qty - temp.QtyBal;
                    }
                    else
                    {
                        temp.Qty = Qty;
                        Qty = 0;
                    }
                    temp.Amount = Common.Amount((temp.Qty * temp.SumPrice).ToString());
                    SumQty += temp.Qty;
                    AccountList.Add(temp);
                }

                if (data.Tables[1].Rows.Count > 0)
                {
                    PageConfirm_Message.Text = "车辆" + PageConfirmCar.Text + "尚未出厂，不能重复开卡。";
                    PageConfirm_Next.Text = "禁止";
                    PageConfirm_Next.Enabled = true;
                }
                else if (SumQty != Common.Qty(PageSales_PreQty.Text))
                {
                    PageConfirm_Message.Text = String.Format("订单余额不足，请补交充值或者调整预装数量重试！剩余:{0}吨", SumBalQty);
                    PageConfirm_Next.Enabled = true;
                    PageConfirm_Next.Text = "确    定";
                }
                else
                {
                    String serial = Device.GetCardAndReturnSerial();
                    if (serial == String.Empty)
                    {
                        PageConfirm_Message.Text = "磁卡用光了，请联系管理人员！";
                        PageConfirm_Next.Enabled = true;
                        PageConfirm_Next.Text = "确    定";
                    }
                    else
                    {
                        int tryTimes = 0;
                        int canTimes = 5;
                        //while (tryTimes < canTimes)
                        //{
                        //    if (Device.UsbCardDevice.WriteBlock(GustName[0], Block.Block04) &&
                        //    Device.UsbCardDevice.WriteBlock(GustName[1], Block.Block05) &&
                        //    Device.UsbCardDevice.WriteBlock(GustName[2], Block.Block06) &&
                        //    Device.UsbCardDevice.WriteBlock(PageConfirmItem.Text, Block.Block08) &&
                        //    Device.UsbCardDevice.WriteBlock(PageConfirmCar.Text, Block.Block09) &&
                        //    Device.UsbCardDevice.WriteBlock(Note, Block.Block10) &&  //备注
                        //    Device.UsbCardDevice.WriteBlock("", Block.Block12) && //收发人
                        //    Device.UsbCardDevice.WriteBlock(PageConfirmQty.Text, Block.Block13) &&
                        //    Device.UsbCardDevice.WriteBlock("正常", Block.Block14) &&
                        //    Device.UsbCardDevice.WriteBlock("销售.已开票", Block.Block16) &&
                        //    Device.UsbCardDevice.WriteBlock("", Block.Block17) && //销售批次编号
                        //    Device.UsbCardDevice.WriteBlock("", Block.Block18)) //生产线
                        //    {
                        //        break;
                        //    }
                        //    else
                        //    {
                        //        //System.Threading.Thread.Sleep(100);
                        //        //Device.UsbCardDevice.ReSet();
                        //        tryTimes++;
                        //    }
                        //}
                        if (tryTimes < canTimes)
                        {
                            sql.Clear();
                            sql.Append("SET NOCOUNT ON\r\n");
                            foreach (AccountTemp temp in AccountList)
                            {
                                sql.AppendFormat("UPDATE KEW_SalesInfoEntry SET FDecimal5={0},FDecimal6={1},FDecimal7={2},FDecimal15={3},FDecimal9={4},FDecimal10={5} WHERE FEntryID={6}\r\n",
                                    temp.QtyBal, temp.AmountBal, temp.ItemPrice, temp.SumPrice, temp.Qty, temp.Amount, temp.ID);
                            }
                            sql.AppendFormat("EXEC KEW_SALES_AUTOCARD '{0}','{1}','{2}',{3},'{4}'", BillID, serial, PageConfirmCar.Text, PageConfirmQty.Text, itemID);
                            sql.Append("SET NOCOUNT OFF\r\n");
                            try
                            {
                                data = new DataSet();
                                adapter = new OleDbDataAdapter(sql.ToString(), conn);
                                adapter.Fill(data);
                                if (data.Tables.Count == 1 && data.Tables[0].Rows.Count == 1 && data.Tables[0].Rows[0][0].ToString() == "TRUE")
                                {
                                    DataRow row = data.Tables[0].Rows[0];
                                    Dictionary<String, String> dic = new Dictionary<String, String>();
                                    dic.Add("磅单单号", row["BillNo"].ToString());
                                    dic.Add("车牌号码", PageConfirmCar.Text);
                                    dic.Add("预装数量", PageConfirmQty.Text);
                                    dic.Add("物料名称", PageConfirmItem.Text);
                                    dic.Add("客户名称", OrgName);
                                    dic.Add("开票时间", row["PlanTime"].ToString());
                                    dic.Add("磁卡编号", row["CardNo"].ToString());
                                    dic.Add("开票人", "");
                                    if (IsInBag)
                                    {
                                        Device.Printer.Print("销售袋装", dic, "");
                                    }
                                    else
                                    {
                                        Device.Printer.Print("销售散装", dic, "");
                                    }
                                    Device.SendCard();
                                    PageConfirm_Message.Text = "办理完毕,请您拿好磁卡,5秒后将自动退出。";
                                    PageConfirm_Next.Text = "欢迎再次使用";
                                    PageConfirm_Next.Visible = false;
                                    PageConfirm_Return.Text = "关闭";
                                    Device.Voice("voice8.wav");
                                    Device.CountDown = 6;
                                }
                                else
                                {
                                    PageConfirm_Message.Text = "执行错误,请联系管理人员:" + data.Tables[0].Rows[0][1].ToString();
                                    PageConfirm_Next.Enabled = true;
                                    PageConfirm_Next.Text = "确    定";
                                }
                            }
                            catch (Exception ex)
                            {
                                PageConfirm_Message.Text = "数据访问错误：" + ex.Message;
                                PageConfirm_Next.Enabled = true;
                            }
                        }
                        else
                        {
                            Device.ReviceCard();
                            PageConfirm_Message.Text = "出现错误，请重新尝试。" + Device.UsbCardDevice.Flag;
                            PageConfirm_Next.Text = "重    试";
                            PageConfirm_Next.Enabled = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                PageConfirm_Message.Text = "数据访问错误：" + ex.Message;
                PageConfirm_Next.Text = "确    定";
                PageConfirm_Next.Enabled = true;
            }

            ButtonEnd();

        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            Application.DoEvents();
            //Device.Voice("voice7.wav");
        }

        private void ButtonCarNoCHS_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            String value = ((Button)sender).Text;
            if (PageCar_Text.Text.Length == 0)
            {
                PageCar_Text.Text = value;
            }
            else
            {
                if (System.Text.Encoding.GetEncoding("GBK").GetBytes(PageCar_Text.Text.Substring(0, 1)).Length != 1)
                {
                    PageCar_Text.Text = value + PageCar_Text.Text.Substring(1, PageCar_Text.Text.Length - 1);
                }
                else
                {
                    PageCar_Text.Text = value + PageCar_Text.Text;
                }
            }
        }

        private void ButtonCarNoChar_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            if (PageCar_Text.Text.Length < CarLength)
            {
                String value = ((Button)sender).Text;
                PageCar_Text.Text += value;
            }
        }

        private void PageCar_Clear_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            PageCar_Text.Text = String.Empty;
        }

        private void PageCar_Delete_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            if (PageCar_Text.Text.Length > 0)
            {
                PageCar_Text.Text = PageCar_Text.Text.Substring(0, PageCar_Text.Text.Length - 1);
            }
        }

        private void ButtonItemNum_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            String value = ((Button)sender).Text;
            if (Common.CDec(PageSales_PreQty.Text) == 0)
            {
                PageSales_PreQty.Text = value;
            }
            else
            {
                if (PageSales_PreQty.Text.Length < QtyLength)
                {
                    PageSales_PreQty.Text += value;
                }
            }
        }

        private void PageSales_ItemDelete_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            if (PageSales_PreQty.Text.Length > 0)
            {
                PageSales_PreQty.Text = PageSales_PreQty.Text.Substring(0, PageSales_PreQty.Text.Length - 1);
            }
        }

        private void PageSales_ItemClear_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            PageSales_PreQty.Text = String.Empty;
        }

        private void MainTab_Selecting(object sender, TabControlCancelEventArgs e)
        {
            if (e.TabPageIndex == 0 && BillID != String.Empty)
            {
                e.Cancel = true;
                return;
            }
            if (e.TabPageIndex != 0 && BillID == String.Empty)
            {
                e.Cancel = true;
                return;
            }
            switch (e.TabPageIndex)
            {
                case 0:
                    //Device.Voice("voice7.wav");
                    break;
                case 1:
                    if (PageCar_Panel.Enabled)
                    {
                        PageCar_Message.Text = "请输入您的车牌号。";
                        Device.Voice("voice2.wav");
                    }
                    else
                    {
                        PageCar_Message.Text = "车牌号不能修改，请直接点击下一步选择产品及数量";
                    }
                    break;
                case 2:
                    if (PageSales_ItemList.Enabled && PageSales_QtyPanel.Enabled)
                    {
                        PageSales_PreMessage.Text = "请选择一个产品并且输入本次计划运输的数量。";
                        Device.Voice("voice3.wav");
                    }
                    else if (PageSales_ItemList.Enabled)
                    {
                        PageSales_PreMessage.Text = "请选择一个产品。";
                        Device.Voice("voice4.wav");
                    }
                    else if (PageSales_QtyPanel.Enabled)
                    {
                        PageSales_PreMessage.Text = "请输入本次计划运输的数量。";
                        Device.Voice("voice5.wav");
                    }
                    else
                    {
                        PageSales_PreMessage.Text = "产品和数量不能修改，请直接点击下一步确认出卡。";
                    }
                    break;
                case 3:
                    if (PageCar_Text.Text == String.Empty || PageSales_ItemList.SelectedItem == null || Common.CDec(PageSales_PreQty.Text) == 0)
                    {
                        e.Cancel = true;
                        return;
                    }
                    Device.Voice("voice6.wav");
                    PageConfirmCar.Text = PageCar_Text.Text;
                    PageConfirmItem.Text = ((ListTemp)PageSales_ItemList.SelectedItem).Name;
                    PageConfirmQty.Text = PageSales_PreQty.Text;
                    break;
            }
        }

        private void ButtonCancel_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            Exit();
        }

        private void Exit()
        {
            this.Close();
        }

        private void Clear()
        {
            PageSales_NumText.Text = String.Empty;
            PageCar_Text.Text = String.Empty;
            PageSales_PreQty.Text = String.Empty;
            SalesTab.SelectedTab = TabPageInputBillNo;
        }

        private void PageConfirm_Return_Click(object sender, EventArgs e)
        {
            Device.ButtonVoice();
            if (PageConfirm_Return.Text == "关闭")
            {
                this.Close();
            }
            else
            {
                SalesTab.SelectedTab = TabPageInuputCarNo;
            }
        }



        private void MainForm_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.Back:
                    Exit();
                    break;
                case Keys.Escape:
                    Exit();
                    break;
            }


        }

        private void SalesForm_SizeChanged(object sender, EventArgs e)
        {
            SalesTab.Size = this.Size;
            PageSales_NumText.Size = new Size(this.Size.Width, PageSales_NumText.Size.Height);
        }

        private void MainTimer_Tick(object sender, EventArgs e)
        {
            if (Device.CountDown > 0)
            {
                Device.CountDown--;
            }
            else if (Device.CountDown == 0)
            {
                this.Close();
            }

            label7.Text = Device.UsbCardDevice.Flag;
        }


        private List<AccountTemp> AccountList = new List<AccountTemp>();

        private String BillID = String.Empty;
        private String Gust = String.Empty;
        private String Note = String.Empty;

        

        private void PageSales_ItemList_SelectedIndexChanged(object sender, EventArgs e)
        {
            Device.ButtonVoice();
        }

        private void ButtonTimer_Tick(object sender, EventArgs e)
        {
            if (!IsButtonEnable && DateTime.Now - ButtonOverTime > TimeSpan.FromMilliseconds(800))
            {
                IsButtonEnable = true;
                PageSales_NumNext.Enabled = true;
                PageSales_NumCancel.Enabled = true;
                PageCar_Next.Enabled = true;
                PageCar_Cancel.Enabled = true;
                PageSales_QtyNext.Enabled = true;
                PageSales_QtyCancel.Enabled = true;
                PageConfirm_Next.Enabled = true;
            }
        }

        private void PageSales_NumText_TextChanged(object sender, EventArgs e)
        {
            LabNumberCount.Text = PageSales_NumText.Text.Length.ToString();
        }

    }

    enum EnumStep
    { 
        InputBillNo,
        InputCarNo,
    }

    enum EnumStepRight
    {
        Edit,
        View,
        Forbid
    }

    public class ListTemp
    {
        public String ID { get; set; }
        public String Name { get; set; }
        public Decimal BagQty { get; set; }
    }

    public class AccountTemp
    {
        public String ID { get; set; }
        public String Source { get; set; }
        public Decimal AmountBal { get; set; }
        public Decimal ItemPrice { get; set; }
        public Decimal SumPrice { get; set; }
        public Decimal QtyBal { get; set; }
        public Decimal Qty { get; set; }
        public Decimal Amount { get; set; }
    }
}
